using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// CheckOut 的摘要说明。
	/// </summary>
	public class CheckOut : BaseDAL<CheckOutInfo>, ICheckOut
	{
		#region 对象实例及构造函数

		public static CheckOut Instance
		{
			get
			{
				return new CheckOut();
			}
		}
		public CheckOut() : base("KF_CheckOut","ID")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override CheckOutInfo DataReaderToEntity(IDataReader dataReader)
		{
			CheckOutInfo checkOutInfo = new CheckOutInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			checkOutInfo.ID = reader.GetInt32("ID");
			checkOutInfo.CheckOutNo = reader.GetString("CheckOutNo");
			checkOutInfo.RoomNo = reader.GetString("RoomNo");
			checkOutInfo.CustomerName = reader.GetString("CustomerName");
			checkOutInfo.CompanyName = reader.GetString("CompanyName");
			checkOutInfo.Customer_ID = reader.GetInt32("Customer_ID");
			checkOutInfo.OrderNo = reader.GetString("OrderNo");
			checkOutInfo.Order_ID = reader.GetInt32("Order_ID");
			checkOutInfo.ConsumptionAmount = reader.GetDecimal("ConsumptionAmount");
			checkOutInfo.Amount = reader.GetDecimal("Amount");
			checkOutInfo.DepositRecieved = reader.GetDecimal("DepositRecieved");
			checkOutInfo.Offers = reader.GetDecimal("Offers");
			checkOutInfo.DicountRate = reader.GetDouble("DicountRate");
			checkOutInfo.PaidAmount = reader.GetDecimal("PaidAmount");
			checkOutInfo.PayType = reader.GetString("PayType");
			checkOutInfo.HasInvoicing = reader.GetBoolean("HasInvoicing");
			checkOutInfo.Note = reader.GetString("Note");
			
			return checkOutInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(CheckOutInfo obj)
		{
		    CheckOutInfo info = obj as CheckOutInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("CheckOutNo", info.CheckOutNo);
 			hash.Add("RoomNo", info.RoomNo);
 			hash.Add("CustomerName", info.CustomerName);
 			hash.Add("CompanyName", info.CompanyName);
 			hash.Add("Customer_ID", info.Customer_ID);
 			hash.Add("OrderNo", info.OrderNo);
 			hash.Add("Order_ID", info.Order_ID);
 			hash.Add("ConsumptionAmount", info.ConsumptionAmount);
 			hash.Add("Amount", info.Amount);
 			hash.Add("DepositRecieved", info.DepositRecieved);
 			hash.Add("Offers", info.Offers);
 			hash.Add("DicountRate", info.DicountRate);
 			hash.Add("PaidAmount", info.PaidAmount);
 			hash.Add("PayType", info.PayType);
 			hash.Add("HasInvoicing", info.HasInvoicing);
 			hash.Add("Note", info.Note);
 				
			return hash;
		}

    }
}